package com.temp.controller.user;

import com.temp.dto.SearchTranRecordDTO;
import com.temp.entity.User;
import com.temp.result.Result;
import com.temp.service.WithdrawService;
import com.temp.utils.ShiroUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/transaction")
@Api(tags = "交易记录相关接口")
@Slf4j
@Validated
public class TransactionRecordController {

    @Autowired
    private WithdrawService withdrawService;

    @PostMapping("/query")
    @ApiOperation("查询交易记录")
    @RequiresPermissions("user:transaction:query")
    public Result getTransactionRecords(@RequestBody SearchTranRecordDTO searchTranRecordDTO) {
        searchTranRecordDTO.formatParam();
        User user = ShiroUtils.getUser();
        searchTranRecordDTO.setUserId(user.getId());
        return Result.success(withdrawService.findAllTransactionRecords(searchTranRecordDTO),"apiMsg.querySuccess");
    }
}
